#include	<unistd.h>
#include	<sys/stat.h>
#include	<sys/types.h>
#include	<stdio.h>
#include	<fcntl.h>

int	main()
{
  int	i;
  int	in;
  int	out;
  char	buffer[1025];

  i = mkfifo("totofifo", 0777);
  if (i == -1)
    {
      perror("mkfifo");
      return (0);
    }
  i = fork();
  if (i == 0)
    {
      out = open("totofifo", O_RDONLY);
      i = read(out, buffer, 1024);
      buffer[i] = '\0';
      write(1, buffer, strlen(buffer));
      i = read(out, buffer, 1024);
      buffer[i] = '\0';
      write(1, buffer, strlen(buffer));
      close(out);
      return (0);
    }
  else
    {
      in = open("totofifo", O_WRONLY);
      write(in, "toto\n", 5);
      write(in, "tutu\n", 5);
      sleep(5);
      close(in);
      remove("totofifo");
    }
  return (0);
}
